﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Service.Application.AccountService;
using Service.Application.Interface;
using Service.Domain.Entities;
using Service.Domain.Entities.User;
using Service.Domain.Shared.Models;
using Service.Infrastructure.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Service.API.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class AccountController : ControllerBase
    {
        readonly IAccountAppService appService;
        readonly ICacheManager cacheManager;

        public AccountController(IAccountAppService appService, ICacheManager cacheManager)
        {
            this.appService = appService;
            this.cacheManager = cacheManager;
        }

        [AllowAnonymous]
        [HttpPost]
        [Route("api/Account/Login")]
        public async Task<object> Login(LoginDto user)
        {
            return await appService.Login(user);
        }

        [HttpPost]
        public UserInfo GetLoginUser()
        {
            return appService.GetLoginUser();
        }
    }
}
